package com.yifushidai.api;

import com.yifushidai.service.MacUnbindService;
import com.yifushidai.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api(tags = "设备解绑")
@RequestMapping("/api/mac")
public class MacUnbindController {

    @Autowired
    private MacUnbindService macUnbindService;

    @PostMapping("/queryByMac")
    @ApiOperation(value = "查询门锁、插卡、控电设备绑定状态接口", notes = "根据联网盒mac查询：lockMac（门锁mac）、cardMac（插卡设备mac）、powerMac（控电设备mac）绑定状态", produces = MediaType.APPLICATION_JSON_VALUE)
    public R queryByMac(@ApiParam(value = "联网盒mac", required = true) @RequestParam String mac) throws Exception {
        return macUnbindService.queryByMac(mac);
    }


    @PostMapping("/lockMacUnbind")
    @ApiOperation(value = "门锁mac解绑接口", notes = "门锁mac解绑", produces = MediaType.APPLICATION_JSON_VALUE)
    public R lockMacUnbind(@ApiParam(value = "联网盒mac", required = true) @RequestParam String mac,
                           HttpServletRequest request) throws Exception {
        return macUnbindService.lockMacUnbind(mac, request);
    }

    @PostMapping("/cardMacUnbind")
    @ApiOperation(value = "插卡设备mac解绑接口", notes = "插卡设备mac解绑", produces = MediaType.APPLICATION_JSON_VALUE)
    public R cardMacUnbind(@ApiParam(value = "联网盒mac", required = true) @RequestParam String mac,
                           HttpServletRequest request) throws Exception {
        return macUnbindService.cardMacUnbind(mac, request);
    }

    @PostMapping("/powerMacUnbind")
    @ApiOperation(value = "控电设备mac解绑接口", notes = "控电设备mac解绑", produces = MediaType.APPLICATION_JSON_VALUE)
    public R powerMacUnbind(@ApiParam(value = "联网盒mac", required = true) @RequestParam String mac,
                            HttpServletRequest request) throws Exception {
        return macUnbindService.powerMacUnbind(mac, request);
    }
}
